import matplotlib.pyplot as plt

x = ['a', 'b', 'c', 'd']
y = [10, 14, 5, 40]

rect = plt.bar(x, y, color='r', width=0.4)

# 绘制标度值
for index, item in enumerate(rect):
    _x = item.get_x() + 0.15
    _y = item.get_height()
    plt.text(_x, _y, y[index])

# 显示网格
plt.grid(True)

#调整坐标
plt.ylim(0, 50)

plt.show()
